package com.zhijian.medical.controller;

import com.zhijian.medical.annotation.Response;
import com.zhijian.medical.entity.po.Device;
import com.zhijian.medical.entity.po.ExperimentProcessKzy;
import com.zhijian.medical.entity.vo.response.ExperimentProcessKzyVo;
import com.zhijian.medical.entity.vo.response.ExperimentProcessOfKzyVo;
import com.zhijian.medical.service.DeviceService;
import com.zhijian.medical.service.ExperimentProcessKzyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * 实验流程-核酸扩增一区-扩增仪数据 控制层
 *
 * @author HCG
 * @version 1.0
 * @date 2022-07-08 22:08:35
 */
@Slf4j
@Controller
@Api(tags = "实验流程-核酸扩增一区-扩增仪数据")
public class ExperimentProcessKzyController {

    @Autowired
    private ExperimentProcessKzyService service;

    @Autowired
    private DeviceService deviceService;

    /**
     * 新增or修改
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/experiment/process/kzy")
    @ApiOperation("新增or修改")
    public boolean insert(@RequestBody ExperimentProcessKzy param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return service.saveOrUpdate(param);
    }

    /**
     * 根据实验流程id与设备id查询
     *
     * @param experimentProcessId
     * @param deviceId
     * @return
     */
    @Response
    @GetMapping("/experiment/process/kzy/{experimentProcessId}/{deviceId}")
    @ApiOperation("根据实验流程id与设备id查询")
    public ExperimentProcessKzyVo selectById(@PathVariable("experimentProcessId") Long experimentProcessId, @PathVariable("deviceId") Long deviceId) {
        return service.selectVoByExperimentProcessIdAndDeviceId(experimentProcessId, deviceId);
    }

    /**
     * 查询一个实验流程的扩增仪列表
     *
     * @return
     */
    @Response
    @GetMapping("/experiment/process/kzy/list/{experimentProcessId}")
    @ApiOperation("查询一个实验流程的扩增仪列表")
    public List<Device> selectKzyList(@PathVariable("experimentProcessId") Long experimentProcessId) {
        return deviceService.selectListByExperimentProcessId(experimentProcessId);
    }

    /**
     * 查询一个实验流程的扩增仪所有数据列表
     *
     * @param experimentProcessId
     * @return
     */
    @Response
    @GetMapping("/experiment/process/kzy/all/data/{experimentProcessId}")
    @ApiOperation("查询一个实验流程的扩增仪所有数据列表")
    public List<ExperimentProcessOfKzyVo> selectExperimentProcessOfKzyVoByExperimentProcessId(@PathVariable("experimentProcessId") Long experimentProcessId) {
        return service.selectExperimentProcessOfKzyVoByExperimentProcessId(experimentProcessId);
    }

}